import requests


def get_chat_id(token):
    url = f"https://api.telegram.org/bot{token}/getUpdates"
    response = requests.get(url)
    updates = response.json()

    if updates['result']:
        chat_id = updates['result'][0]['message']['chat']['id']
        print(f"你的 Chat ID 是: {chat_id}")
        return chat_id
    else:
        print("请先给机器人发送一条消息")
        return None


# 使用
# BOT_TOKEN = "8375300563:AAG88IfT6BWWbTABtRS679aSDVwD2NTgCkk"
# BOT_TOKEN = "8360527491:AAGhw2KSs-Ctfnzbregjj8vSHxBCaHGsd_M"
BOT_TOKEN = "8405992519:AAF6ydOzq1miJa0spNM4x2zB-SgRB0CObzg"
get_chat_id(BOT_TOKEN)